﻿#include "widget.h"
#include "ui_widget.h"
#include <QQuickWidget>
#include <QPixmap>
#include <QPalette>
#include <QColor>
#include <QQmlEngine>
#include <QQmlContext>
#include <QDate>
#include <QSettings>
#include <QDir>
#include <QTextStream>
#include <QDesktopWidget>
#include <QApplication>
#include <QDebug>
#include <iostream>

#include "game.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget),
    w(400),
    h(300)
{
    ui->setupUi(this);

    ui->quickWidget->engine()->rootContext()->setContextProperty("widget",this);

    ui->quickWidget->setSource(QUrl("qrc:/qml/main.qml"));

    this->setFixedSize(w, h);

    setWindowTitle("Memento 备忘录");

    Originator originator;
    Memento* aMemento = originator.CreateMemento();
    originator.PrintState();

    originator.Handle();
    originator.PrintState();

    originator.Handle();
    originator.PrintState();

    originator.SetMemento(aMemento);
    delete aMemento;

    originator.PrintState();
}

Widget::~Widget()
{
    delete ui;
}

void Widget::systemExit(bool b)
{    
    (void)b;
    qApp->quit();
}
